package cn.dengta.webapp.user.form;

import cn.dengta.common.context.I18N;
import cn.dengta.common.util.Validators;
import cn.dengta.common.validator.Check;
import cn.dengta.common.validator.NotEmpty;
import cn.dengta.common.validator.Trim;
import cn.dengta.context.model.UserFormI18nKey;
import cn.dengta.context.model.UserI18nKey;
import cn.dengta.webapp.base.form.BaseForm;
import cn.dengta.webapp.user.entity.User;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class FindPwdForm extends BaseForm<User> {

	@Check(UserFormI18nKey.USER_LOGIN_FORM_USERNAME)
	@Trim
	@NotEmpty
	public String credential;
	@Check(UserFormI18nKey.USER_LOGIN_FORM_PASSWORD)
	@Trim
	@NotEmpty
	public String newPwd;
	@Check(value = UserFormI18nKey.USER_LOGIN_FORM_CAPTCHA, required = false)
	@Trim
	@NotEmpty
	public String captcha;

	@Override
	public void validate() {
		I18N.assertTrue(Validators.matchPassword(newPwd), UserI18nKey.PASSWORD_FORMAT_SET_ERROR);
	}

}
